//
//  SPHelper.m
//  uteped_sdk
//
//  Created by mateng on 2024/2/20.
//

#import "SPHelper.h"

@implementation SPHelper

static SPHelper* instance = nil;

+ (SPHelper*) shareInstance
{
    if ( instance == nil ) {
        instance = [[SPHelper alloc] init];
    }
    return instance;
}

- (void)putObject:(nonnull NSString *)key value:(nullable id)value {
    [[NSUserDefaults standardUserDefaults] setObject:value forKey:key];
    [[NSUserDefaults standardUserDefaults] synchronize];
}

- (void)removeObject:(nonnull NSString *)key  {
    [[NSUserDefaults standardUserDefaults] removeObjectForKey:key];
}

- (id)getObject:(nonnull NSString *)key defaultValue:(nullable id) defaultVaue {
    id data = [[NSUserDefaults standardUserDefaults] objectForKey:key];
    if (data == nil && defaultVaue != nil) {
        return defaultVaue;
    }
    
    return data;
}



@end
